package com.bracketbird.client.gui.club.tournament;


import com.google.gwt.event.dom.client.*;
import com.bracketbird.clientcore.appcontrol.*;
import com.bracketbird.clientcore.gui.*;
import com.bracketbird.clientcore.style.*;

/**
 *
 */
public class CreateChallengerPage extends SubPage<CreateChallengerPageController> {

    private ListBoxComponent tournamentType;


    public CreateChallengerPage() {
        super();
    }


    public void doInit() {

        getContent().add(new LabelComponent("A challenger is ...."), new TextLayout().padding(10, 0, 0, 0).sizeSmall().colorBaseDark());


    }

    public String getHeader() {
        return "Create a Challenger";
    }



    protected void setSubPageHolder(Page subPage) {
        //ignore
    }


    public ListBoxComponent getChallengerType() {
        if (tournamentType == null) {
            tournamentType = new ListBoxComponent();
            tournamentType.addItem("Select challenger type");
            tournamentType.addItem("Add seeding play");
            tournamentType.addItem("Add group play");
            tournamentType.addItem("Add cup play");
            tournamentType.addItem("Remove last added item");

            tournamentType.getListBox().setVisibleItemCount(1);
            tournamentType.getListBox().setSelectedIndex(0);

            tournamentType.getListBox().addChangeHandler(new ChangeHandler() {
                public void onChange(ChangeEvent event) {
                    String text = tournamentType.getListBox().getItemText(tournamentType.getSelectedIndex());
                    if (text.equals("Add item...")) {
                    }
                    else {
                            if (text.equals("Add seeding play")) {
                            }
                            else if (text.equals("Add group play")) {

                            }
                            else if (text.equals("Add cup play")) {
                            }
                            else if (text.equals("Remove last added item")) {
                            }
                            else {
                                throw new SystemException("type :" + text + " is not supported");
                            }
                    }
                }

            });
        }
        return tournamentType;
    }


}